#pragma once

#include <QList>
#include <QPointF>
#include <QObject>
#include <QString>

#include "HHModel.h"
#include "QInhibitorSynapseModel.h"
#include "QChemicalSynapseModel.h"

class QNerveTissue: public QObject
{
    Q_OBJECT
private:

protected:
    int type;
    double memPot;
    double tempMemPot;

    bool curveVisible;
    bool sender;

    QString nerveName;
    int id;

    QList<QNerveTissue*> receiver;
    QList<int> receiverID;

    QPointF pos;

    //Neuron == 1
    HHModel *neuronModel;
    //Receptor == 2
    bool switchedOn;
    //Transmitter == 3
    //ElectricSynapse == 4
    //IngibitorSynapse == 5
    QInhibitorSynapseModel *inhibitorModel;
    //ChemicalSynapse == 6
    QChemicalSynapseModel *chemicalModel;

    double multiplier;
    double relaxTime;

public:
    QNerveTissue();

    virtual int getType(void);

    virtual void addTempMemPot(double _tempMemPot);
    virtual void spreadMemPot(void);
    virtual void rotMemPot(void);

    virtual void setID(int _id);
    virtual int getID(void);

    void addReceiver(QNerveTissue* _receiver);
    void removeReceiverAt(int at);
    void clearReceiverList(void);
    QList<QNerveTissue*> getReceiverList(void);
    QList<int> getReceiverIDList(void);

    void setPos(QPointF _pos);
    virtual QPointF getPos(void);

    void updateReceiverIDList(void);
    void setReceiverIDList(QList<int> _receiverID);

    bool isCurveVisible(void);
    bool isSender(void);

    virtual double getMemPot(void);
    double getMultiplier(void);
    double getRelaxTime(void);

    virtual QString getState(void);

public slots:
    virtual void setMemPot(double _memPot);
    void setMultiplier(double _multiplier);
    void setRelaxTime(double _relaxTime);

    virtual void switchMode();
    bool isSwitchedOn(void);

    void toggleCurveVisible(bool _curveVisible);
    void toggleIsSender(bool _sender);

signals:
    void memPotChanged(double memPot);
    void multiplierChanged(double multiplier);
    void relaxTimeChanged(double relaxTime);
    void idChanged(int);

    void modeChanged(bool switchedOff);
    void stateChanged(const QString &text);

    void curveVisibleToggled(bool curveVisible);
    void isSenderToggled(bool isSender);

};
